<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/19
  Time: 8:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/static/js/vue.js"></script>
    <script type="text/javascript" src="/static/js/axios.min.js"></script>
</head>
<body>
<h1>index</h1>

<div id="app">
    <h2>短信校验码</h2>
    <input type="text" name="tel" id="tel" v-model="tel"/>
    <input type="button" value="getCode" id="getCode" @click="getCode">
    <input type="text" name="code" id="code" v-model="code"/>

    <input type="button" value="login" id="login" @click="login">

</div>

<script>
    let vm = new Vue({
        el: "#app",
        data: {
            tel:"12345678911",
            code: ""
        },
        methods: {
            getCode() {
                axios.get("/code")
                    .then(function (result) {
                        console.log(result)
                        if (result.data.code == 200) {
                            vm.code = result.data.result
                            console.log("---" + result.data.result)
                        } else {
                            alert(result.data.msg)
                        }

                    })
            },
            login() {
                //if r.data.result.code==10001{//进行特定的操作}
                axios.post("/login?code="+ vm.code).then(r => alert(r.data.msg))
            }
        }
    });
</script>
</body>
</html>
